package fr.ece.ing4.javafinance.lab1;

import java.awt.Button;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;


public class SimpleWindow {
	private Frame frame;

	public SimpleWindow() {
        frame = new Frame("Click the button");
        frame.setSize(new Dimension(250, 200));
        frame.setLayout(new FlowLayout(FlowLayout.CENTER));
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        Button red = new Button("Red");
        red.addActionListener(new ButtonHandler());
        frame.add(red);
        frame.setVisible(true);
    }

	private class ButtonHandler implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			frame.setBackground(Color.RED);
		}
	}

	public static void main(String[] args) {
		new SimpleWindow();
	}
}
